package client.comm.baoding.adapter.page

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.viewpager.widget.PagerAdapter
import client.comm.baoding.fragment.*

class OrderFragmentPageAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) {

    override fun getItem(position: Int): Fragment {

        return when (position) {
            0 -> GoodsOrderOneFragment()
            1 -> GoodsOrderZeroFragment()
            2 -> GoodsOrderTwoFragment()
            3 -> GoodsOrderThreeFragment()
            4 -> GoodsOrderFourFragment()
            else -> GoodsOrderOneFragment()
        }
    }

    override fun getCount(): Int {
        return 5
    }

    override fun getPageTitle(position: Int): CharSequence? {
        var title = ""
        when (position) {
            0 -> {
                title = "全部"
            }
            1 -> {
                title = "待支付"
            }
            2 -> {
                title = "待发货"
            }
            3 -> {
                title = "待收货"
            }
            4 -> {
                title = "已完成"
            }
        }
        return title
    }

    override fun getItemPosition(`object`: Any): Int {
        return POSITION_NONE
    }

}